#ifndef _POLYGON_H_
#define _POLYGON_H_

#include <mat.h>
#include <vec.h>

typedef struct  
{
	int a;
	int b;
	double nx;
	double ny;
} Edge;

typedef struct  
{
	double x;
	double y;
	int ea;
	int eb;
	double nx;
	double ny;
} Vert;

typedef void(*initializeFunc)(Edge**, Vert**, int*, int*);

class Polygon
{
public:
	Polygon(void);
	~Polygon(void);

	void buildPolyStructure(initializeFunc setUp);

	void constructEdgeNormal();
	void constructVertNormal();

	void translatePolygon(Vec2d translate);
	void rotatePolygon(Mat22d rotate);

	void getShortestDistanceFromPointToLine(int index, Vec2d point, double* dist, Vec2d* cpt, Vec2d* cn);
	void getShortestDistanceFromPointToPoly(Vec2d point, double* dist, Vec2d* cpt, Vec2d* cn);
	bool getSideInfo(int index, Vec2d point);
	bool getInclusionInfo(Vec2d point);
	double getAngle(double x1, double y1, double x2, double y2);

	Edge* edgeList;
	Vert* vertList;

	int edgeCount;
	int vertCount;
};

#endif

